package main

import "fmt"

func main() {

	arr := []int{0}
	fmt.Println("arr is ", arr)

	arr = append(arr, 1, 2, 3, 4)

	fmt.Println("append a elem: arr=", arr)

	arr1 := make([]int, 10, 17)
	copy(arr1, arr) // 将arr index对应的值赋值给arr1，
	fmt.Println("copy from arr: arr1=", arr1)

	//delete

	arr1 = append(arr1[:3], arr1[4:]...) // arr1[4:]... 表示对这个切片的一个遍历: elem ...Type
	fmt.Println("delete the 4th elem: arr1=", arr1)

	arr1 = arr1[1:] //delete the 1th elem
	fmt.Println("delete the 1th elem, arr1=", arr1)

	arr1 = arr1[:len(arr1)-1]
	fmt.Println("delete the end elem, arr1=", arr1)
	/**
	运行结果：
	arr is  [0]
	append a elem: arr= [0 1 2 3 4]
	copy from arr: arr1= [0 1 2 3 4 0 0 0 0 0]
	delete the 4th elem: arr1= [0 1 2 4 0 0 0 0 0]
	delete the 1th elem, arr1= [1 2 4 0 0 0 0 0]
	delete the end elem, arr1= [1 2 4 0 0 0 0]
	*/
}
